﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LHWebApp.html
{
    public partial class WeightVehicle : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //string clientNo = Request.Params["userClientNo"];
                //string currentService = Request.Params["currentService"];
                string clientName = Request.Params["clientName"];
                string date = Request.Params["dateString"];
                string name = Request.Params["name"];
                //if (string.IsNullOrEmpty(clientNo))
                //{
                //    //context.Response.Write("{success: false}");
                //}
                //else
                //{
                    try
                    {
                        DataTable dt = LHWebApp.Services.GetVehicleWeightByFactoryAndDistrictBh(clientName, date, name).Tables[1];//2019.09.20 zx

                        JSONHelper jsonHelp = new JSONHelper();
                        jsonHelp.success = true;
                        jsonHelp.totlalCount = dt.Rows.Count;
                        if (jsonHelp.totlalCount == 0)
                        {
                            //context.Response.Write("{success: true}");
                        }
                        else
                        {
                            this.GridViewWeightVehicle.DataSource = dt;
                            this.GridViewWeightVehicle.DataBind();
                            //foreach (DataRow dr in dt.Rows)
                            //{
                            //    jsonHelp.AddItem("type", dr[0].ToString());
                            //    jsonHelp.AddItem("carCountOnline", dr[1].ToString());
                            //    jsonHelp.AddItem("carCountAll", dr[2].ToString());
                            //    jsonHelp.ItemOk();
                            //}
                            //context.Response.Write(jsonHelp.ToString());
                        }
                    }
                    catch (Exception)
                    {
                        //context.Response.Write("{success: false}");
                    }

                //}
            }
        }
    }
}